﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AdminAreaValidation.cs" company="emrecoskun.net">
//   ecblog.codeplex.com - emrecoskun.net
// </copyright>
// <summary>
//   The admin area validation
// </summary>
// --------------------------------------------------------------------------------------------------------------------
 
namespace EcBlog.Models.Validations
{
    using System.ComponentModel.DataAnnotations;

    /// <summary>
    /// The admin area validation
    /// </summary>
    public class AdminAreaValidation : ValidationAttribute
    {
        /// <summary>
        /// Determines whether the specified value of the object is valid.
        /// </summary>
        /// <param name="value">The value of the object to validate.</param>
        /// <returns>
        /// true if the specified value is valid; otherwise, false.
        /// </returns>
        public override bool IsValid(object value)
        {
            return (value ?? string.Empty).ToString().ToLower().IndexOf("admin", System.StringComparison.Ordinal) != 0;
        }
    }
}